You are here: Trading System Programming > Reference > Classes > Account > Account Methods > getPositions

getPositions

The getPositions method returns an array of Position objects representing all open positions.

Syntax

var getPositions(symbol, positionType);

Parameters

symbol

String value representing a symbol for which to return positions. Specify null to return an array for all symbols.

 

positionType

One of the position types. Specify null to return an array for all position types.

Return Value

This method returns an array of Position objects.

Example

The following example demonstrates the use of getPositions() method.

 

function start()

{

//retrieve short positions for all symbols

var account = getAccount();

var positions = account.getOrders(null, POSITIONTYPE_SHORT);

 

//loop through all positions

for(var i = 0; i < positions.length, i++)

{

//proceed further...

var position = positions[i];

} 

}

See Also

start(), getAccount(), Position class

 


Copyright © 2006-2009 ActiveTick LLC